package com.huabo.contract.service.impl;

import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import com.huabo.contract.config.DateBaseConfig;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.hbfk.entity.DealUserToken;
import com.hbfk.entity.TblStaffUtil;
import com.hbfk.util.DateUtil;
import com.hbfk.util.PageInfo;
import com.huabo.contract.oracle.entity.TblAttachment;
import com.huabo.contract.oracle.entity.TblCirculation;
import com.huabo.contract.oracle.entity.TblContractAppendixsigning;
import com.huabo.contract.oracle.entity.TblContractSpnode;
import com.huabo.contract.oracle.entity.TblCounterpartBankinfo;
import com.huabo.contract.oracle.entity.TblCswlManagement;
import com.huabo.contract.oracle.entity.TblCyhwBudetgoods;
import com.huabo.contract.oracle.entity.TblCyhwProjectbudget;
import com.huabo.contract.oracle.entity.TblCyhwUnit;
import com.huabo.contract.oracle.entity.TblFlow;
import com.huabo.contract.oracle.entity.TblMyTask;
import com.huabo.contract.oracle.entity.TblProcessAnalusisUser;
import com.huabo.contract.oracle.entity.TblProcessAnalysis;
import com.huabo.contract.oracle.mapper.TblAttachmentMapper;
import com.huabo.contract.oracle.mapper.TblCirculationMapper;
import com.huabo.contract.oracle.mapper.TblContractAppendixsigningMapper;
import com.huabo.contract.oracle.mapper.TblCounterpartBankinfoMapper;
import com.huabo.contract.oracle.mapper.TblCyhwBudetgoodsMapper;
import com.huabo.contract.oracle.mapper.TblCyhwProjectbudgetMapper;
import com.huabo.contract.oracle.mapper.TblCyhwUnitMapper;
import com.huabo.contract.oracle.mapper.TblFlowMapper;
import com.huabo.contract.oracle.mapper.TblFundPoolMapper;
import com.huabo.contract.oracle.mapper.TblMyTaskMapper;
import com.huabo.contract.oracle.mapper.TblProcessAnalusisUserMapper;
import com.huabo.contract.oracle.mapper.TblProcessAnalysisMapper;
import com.huabo.contract.service.TblCirculationService;
import com.huabo.contract.service.TblCyhwProjectbudgetService;
import com.huabo.contract.service.TblFundPoolService;
import com.huabo.contract.util.DateUtils;
import com.huabo.contract.util.HttpClient;

import cn.hutool.json.JSONArray;
import lombok.extern.slf4j.Slf4j;
import net.sf.json.JSONObject;

@Service("TblFundPoolServiceImpl")
@Slf4j
public class TblFundPoolServiceImpl implements TblFundPoolService {
 
	@Resource
	private TblFundPoolMapper fundPoolMapper;

	public void saveTblFundPool(String id, String no, String name)
			throws Exception {
		if(DateBaseConfig.DATABASETYPE.equals("Oracle")) {
			try {
				int size = fundPoolMapper.selectTblFundPool(id);
				if (size > 0) {
					fundPoolMapper.updateTblFundPool(id, no, name);
				} else {
					fundPoolMapper.insertTblFundPool(id, no, name);
				}

			} catch (Exception e) {
				e.printStackTrace();
			}
		} else {
			try {
				int size = fundPoolMapper.selectTblFundPool(id);
				if (size > 0) {
					fundPoolMapper.updateTblFundPool(id, no, name);
				} else {
					fundPoolMapper.insertTblFundPool(id, no, name);
				}

			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	}
	public void updateTblFundPool(String id, String no, String name)
			throws Exception {
		if(DateBaseConfig.DATABASETYPE.equals("Oracle")) {
			try {
				fundPoolMapper.updateTblFundPool(id, no, name);
			} catch (Exception e) {
				e.printStackTrace();
			}
		} else {
			try {
				fundPoolMapper.updateTblFundPool(id, no, name);
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	}
}
